<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/tag.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询用户列表</title>
<LINK rel="stylesheet" type="text/css" href="${baseurl}js/easyui/styles/default.css">
<%@ include file="/WEB-INF/views/common_css.jsp"%>
<%@ include file="/WEB-INF/views/common_js.jsp"%>
<script type="text/javascript">
	function deleteItems() {

		//将form的action指向删除商品的地址
		document.itemsForm.action = "${pageContext.request.contextPath }/user/deleteUser";

		//进行form提交
		document.itemsForm.submit();

	}
	
	/* 表单异步提交 */
	$(function(){
		 $("#submit").click(function(){
			 $.messager.confirm('删除用户', '您确定是否要删除这些用户?', function(r){
					if (r){
				         $("#itemForm").ajaxSubmit({
				       	 	url: "${pageContext.request.contextPath }/user/deleteUser",
				            dataType: "html",//返回数据类型
				            //提交成功后回调函数
				            success: function(returnedDate){
				           	 
				           	 if(returnedDate=="success"){
				           		//选中创建的列表框（并刷新）
			 					parent.parent.$('#tabs').tabs('select','用户管理');
				           	 }else{
				           		 $.messager.alert('删除用户',returnedDate,'info');
				           	 }
				           	 
				            }
				        }); 
					}
			});
		 });
	});
	
</script>
</head>
<body>
	<c:if test="${usercode!=null }">
		<a href="${pageContext.request.contextPath }/logout">退出</a>
	</c:if>

	<form id="itemForm" method="post">
		<table width="100%" border=1>
			<tr>
				<td>
					<input type="button" value="批量删除" id="submit" />
				</td>
				<td>
					<input type="button" value="添加用户" onclick="javascript:createmodalwindow('添加用户',0.43,0.49,'${baseurl}user/add')"/>
<%-- 					<input type="button" value="添加用户" onclick="javascript:addTab2('添加用户','${baseurl}user/add','icon-null')"/> --%>
				</td>
			</tr>
		</table>

		用户列表：
		<table width="100%" border=1 class="huanse">
			<tr>
				<td>选择</td>
				<td>登录账号</td>
				<td>用户名称</td>
				<td>创建日期</td>
				<td>是否锁定</td>
				<td>操作</td>
			</tr>
			<c:forEach items="${userList }" var="item">
				<tr>
					<td><input type="checkbox" name="delete_id"
						value="${item.userId}" /></td>
					<td>${item.usercode }</td>
					<td>${item.username }</td>
					<td><fmt:formatDate value="${item.createtime}"
							pattern="yyyy-MM-dd HH:mm:ss" /></td>
					<td>${item.locked==0?"否":"是" }</td>
					<td>
						<!-- 有item:update权限才显示修改链接，没有该 权限不显示，相当 于if(hasPermission(item:update)) -->
						<shiro:hasPermission name="user:update">
							<a href="javascript:javascript:createmodalwindow('修改用户',0.43,0.49,'${baseurl}user/edit/${item.userId}')">修改用户</a>
<%-- 							<a href="javascript:addTab2('修改用户','user/edit/${item.userId}');">修改用户</a> --%>
						</shiro:hasPermission>
					</td>

				</tr>
			</c:forEach>

		</table>
	</form>
</body>
</html>